package com.tjsinfo.tjsoa.mail.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.common.SessionUser;
import com.tjsinfo.tjsoa.mail.bo.ITjsemailReceivedBo;

/**
 * 删除收件箱
 * @author wangxiaowei
 *
 */
public class DeleteEmailReceivedAction extends Action{
	private ITjsemailReceivedBo tjsemailReceivedBo;
	public ITjsemailReceivedBo getTjsemailReceivedBo() {
		return tjsemailReceivedBo;
	}
	public void setTjsemailReceivedBo(ITjsemailReceivedBo tjsemailReceivedBo) {
		this.tjsemailReceivedBo = tjsemailReceivedBo;
	}
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		String[] strarray = request.getParameterValues("checkbox2");
		//List list =  null;
		/*if (tjsemailReceivedBo.deleteTjsReceived(request.getParameterValues("checkbox2"))) {//删除收件的列表
			//list = tjsemailReceivedBo.selectUserId(String.valueOf(SessionUser.getUserId(request)),SessionUser.getUser(request).getUsername());
			//request.setAttribute("list", list);
			request.setAttribute("linkurl", "tjsinfo/tjsoa/mail/emailReceivedList.do");
			request.setAttribute("message", "email.message.deleteemail");
			return mapping.findForward("success");
		}else {
			return mapping.findForward("error");
		}*/
		for (int i = 0; i < strarray.length; i++) {
			tjsemailReceivedBo.deleteTjsReceived(strarray[i]);
		}
		request.setAttribute("linkurl", "tjsinfo/tjsoa/mail/emailReceivedList.do");
		request.setAttribute("message", "email.message.deleteemail");
		request.setAttribute("count", tjsemailReceivedBo.count(String.valueOf(SessionUser.getUserId(request)),1));
		return mapping.findForward("success");
	}
	
}
